#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include "jeeps/gpsmath.h"
#define MYNAME "CompeGPS"
static short_handle sh;
static int snlen;
static int radius;
+static int input_datum;
static route_head *curr_track;
static route_head *curr_route;
ARG_TERMINATOR
};
+static
+void fix_datum(double *lat, double *lon)
+{
+ double amt;
+ static int wgs84;
+
+ if (wgs84 == 0) {
+ wgs84 = GPS_Lookup_Datum_Index("WGS 84");
+ }
+
+ /*
+ * Avoid FP jitter in the common case.
+ */
+ if (input_datum != wgs84) {
+ GPS_Math_Known_Datum_To_WGS84_M(*lat, *lon, 0.0, lat, lon,
+ &amt, input_datum);
+ }
+}
+
/* specialized readers */
static waypoint*
}
c = csv_lineparse(NULL, " ", "", col++);
}
+ fix_datum(&wpt->latitude, &wpt->longitude);
return wpt;
}
}
c = csv_lineparse(NULL, " ", "", col++);
}
+ fix_datum(&wpt->latitude, &wpt->longitude);
return wpt;
}
compegps_rd_init(const char *fname)
{
fin = gbfopen(fname, "rb", MYNAME);
+ input_datum = GPS_Lookup_Datum_Index("WGS 84");
}
static void
{
char *buff;
int line = 0;
+ int input_datum;
waypoint *wpt = NULL;
route_head *route = NULL;
route_head *track = NULL;
while ((buff = gbfgetstr(fin)))
{
char *cin = buff;
- char *ctail, *cx;
+ char *ctail;
line++;
cin = lrtrim(buff);
switch(*cin)
{
case 'G':
- cx = csv_stringclean(ctail, " ");
- is_fatal((strcmp(cx, "WGS84") != 0), MYNAME ": Unsupported datum \"%s\"!", ctail);
- xfree(cx);
+ input_datum = GPS_Lookup_Datum_Index(ctail);
+ if (input_datum < 0) {
+ fatal( MYNAME ": Unsupported datum \"%s\"!", ctail);
+ }
break;
case 'U':
switch(*ctail)